<template>
  <div class="search" :style="rootStyle">
    <img src="../../static/home/search.png" class="search-icon">
    <input type="text" :value="value"
           :placeholder="placeholderStr" class="search-text"
           @confirm="search"
           @input="$emit('input', $event.target.value)">
  </div>
</template>

<script>
export default {
  props: {
    placeholderStr: {
      type: String,
      default: '输入产品名或型号'
    },
    value: {
      type: String,
      default: ''
    },
    rootWidth: {
      type: String,
      default: '100%'
    },
    rootStyle: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {}
  },
  methods: {
    search(e) {
      this.$emit('confirm', e.detail.value)
    }
  }
}
</script>

<style lang="scss" scoped>
.search {
  color: #000;
  width: 100%;
  height: 99rpx;
  box-sizing: border-box;
  box-shadow: 0 0 4rpx rgba(147, 149, 164, 1);
  border-radius: 46rpx;
  background-color: #fff;
  display: flex;
  align-items: center;
  .search-icon {
    width: 41rpx;
    height: 41rpx;
    object-fit: cover;
    padding-left: 40rpx;
  }
  .search-text {
    color: rgba(147, 149, 164, 1);
    font-size: 27rpx;
    font-weight: 400;
    line-height: 40rpx;
    margin-left: 20rpx;
  }
}
</style>
